package org.smr.ministore.service.impl;

import java.util.List;

import org.blade.utils.Pager;

import org.smr.ministore.dao.RoleMapper;
import org.smr.ministore.entities.Role;
import org.smr.ministore.service.RoleService;

import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.stereotype.Service;

@Service("RoleService")
public class RoleServiceImpl implements RoleService {

	@Autowired
	private RoleMapper mapper;
	
	public int save(Role entity) {
		return mapper.insert(entity);
	}

	public int updateById(Role id) {
		return mapper.updateById(id);
	}

	public Role queryById(Long id) {
		return mapper.selectById(id);
	}

	public int deleteById(Long id) {
		return mapper.deleteById(id);
	}

	public Pager<Role> paginate( Role entity, Long pageSize, Long pageNum) {

		Pager<Role> pager = new Pager( pageSize, pageNum );
		List list  = mapper.pagination(entity, pager);
		pager.setEntities(list);
		return pager;
    }
	
	public int batchSave(List<Role> entities) {
		return mapper.batchInsert(entities);
	}

}
